<template>
  <div>
    患者聊天界面
    和我所签约的患者聊天，首先展示患者列表，点击进入聊天界面，有新的消息发来可以及时出现
    <hr/>
    <div>

    <h3>患者列表</h3>
    <el-input v-model="keyword" style="width:200px;"></el-input>
    <el-button type="primary" plain style="margin-right: 1200px;margin-left: 20px;" @click="esfind">搜索</el-button>
    <el-table :data="tableData" stripe style="width: 100%">
    <el-table-column prop="uid" label="用户ID" width="80" align="center"></el-table-column>
    <el-table-column prop="pid" label="病患ID" width="80" align="center"></el-table-column>
    <el-table-column prop="pimage" label="头像" width="100" align="center"></el-table-column>
    <el-table-column prop="pname" label="用户姓名" width="100" align="center"></el-table-column>
    <el-table-column prop="page" label="年龄" width="60" align="center"></el-table-column>
    <el-table-column prop="psex" label="性别" width="50" align="center"></el-table-column>
    <el-table-column prop="pcard" label="身份证号" width="180" align="center"></el-table-column>
    <el-table-column prop="ptel" label="手机号码" width="120" align="center"></el-table-column>
    <el-table-column prop="pbirthday" label="出生日期" width="120" align="center"></el-table-column> 
    <el-table-column prop="paddress" label="居住地址" width="240" align="center"></el-table-column>
    <el-table-column
      label="操作"
      width="320">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="success" size="big">立即沟通</el-button>
      </template> 
    </el-table-column>
  </el-table>
  </div>

  </div>
</template>

<script>
export default {
  mounted(){
    this.patient_init();
  },
  data(){
    return{
      tableData:[{uid:1}],
      keyword:""
    }
  },
  methods:{
    // 初始化表单信息
    patient_init(){
        //收集参数
        // 发送请求
        this.$axios.get("/patient-serv/patientinfo/findAll")
        // 处理响应
        .then(resp=>{
          let r=resp.data;
          if(r.code==200){
            console.log(r.data);
            this.tableData=r.data;
          }

        });
    },

    esfind(){
      if(this.keyword == ""){
        this.patient_init();
        return;
      }
      this.$axios.get("/patient-serv/patientinfo/esfind/"+this.keyword)
      .then(res => {
        var r = res.data;
        console.log(r.data);
        this.tableData=r.data;
      });
    },
    // 立即沟通按钮事件
    handleClick(row){
      this.$router.push("/Doc_Chat");
    }
  }
}
</script>

<style>

</style>